﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using DataLib.Common;
using DataLib.Accounts.Bus;

namespace Ewts.BaseData
{
    public partial class CityAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request["type"] != null && Request["type"].ToString().Trim() != "")
                {
                    hidCityType.Value = Request["type"].ToString().Trim();
                }
                else 
                {
                    hidCityType.Value = "01";
                }
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            //if (this.txtcompanyid.Text.Trim().Length == 0)
            //{
            //    strErr += "公司ID不能为空！\\n";
            //}
           
            if (this.txtcityname.Text.Trim().Length == 0)
            {
                strErr += "城市名称不能为空！\\n";
            }
            if (this.txtprovince.Text.Trim().Length == 0)
            {
                strErr += "所属省份不能为空！\\n";
            }
            if (this.txtstate.Text.Trim().Length == 0)
            {
                strErr += "国家不能为空！\\n";
            }
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            //string companyid = this.txtcompanyid.Text;
            //string citycode = this.txtcitycode.Text;
            string cityname = this.txtcityname.Text;
            string province = this.txtprovince.Text;
            string state = this.txtstate.Text;
            string memo = this.txtmemo.Text;
            string flag1 = hidCityType.Value;




            DataLib.Model.City model = new DataLib.Model.City();

            model.companyid = 0;
            //model.citycode = citycode;
            model.cityname = cityname;
            model.province = province;
            model.state = state;
            model.memo = memo;
            model.flag1 = flag1;

            DataLib.BLL.City bll = new DataLib.BLL.City();
            bll.Add(model);
            DataLib.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "CityList.aspx?type=" + hidCityType.Value);

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("CityList.aspx");
        }
    }
}
